<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	{{--<meta name="viewport" content="width=device-width, initial-scale=1">--}}
	<title>央票通</title>
	<link rel="stylesheet" href="./resource/css/index.css">
	<link rel="stylesheet" href="./resource/css/user_name.css">
</head>
<body>
<!-- 头部 -->
@include('common.index_head');
<!-- 个人中心 -->
<div class="cont-user">
	<div class="user-name">
		<div class="main">
			<div class="name-cont">
				<div class="title">
					<span>找回密码</span>
				</div>
				<div class="form form-pass form-pass-3">
					<form action="/user_set_pwd" onsubmit="return check_all()" method="post">
						<div class="pass-tit">
							<div class="number">3</div>
							<div class="til">设置新密码</div>
						</div>
						<div class="form-group">
							<label for="">设置新密码</label>
							<input type="password" class="form-control" placeholder="请输入密码" id="new_pwd" name="new_pwd" ><span id="t_new"></span>
						</div>
						<div class="form-group">
							<label for="">再次输入新密码</label>
							<input type="password" class="form-control" placeholder="请输入密码" id="sure_pwd" name="sure_pwd" ><span id="t_sure"></span>
						</div>
						<input type="submit" class="btn btn-register" value="确认修改">
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- footer -->
@include('common.index_foot')

<script src="./resource/js/jquery-1.11.3.min.js"></script>
<script src="./resource/js/index.js"></script>
<script>
	function check_all()
	{
		var new_pwd = document.getElementById('new_pwd').value;
		var sure_pwd = document.getElementById('sure_pwd').value;
		var reg=/^\w{6,16}$/
		var status = false;
		if(reg.test(new_pwd)) {
			document.getElementById("t_new").innerHTML = "";
			if(new_pwd == sure_pwd){
				document.getElementById("t_sure").innerHTML = "";
				var ajax = new XMLHttpRequest();
				ajax.onreadystatechange = function () {
					if (ajax.readyState == 4) {
						if (ajax.responseText == 1) {
							document.getElementById("t_new").innerHTML = "<span style='color:red'>不能和以前密码重复</span>";
						}else{
							document.getElementById("t_new").innerHTML = "";
							status = true;
						}
					}
				}
				//与服务器建立连接
				ajax.open('post', '/verify_set_pwd', false);
				ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				//处理请求
				ajax.send('new_pwd=' +new_pwd);
			}else{
				document.getElementById('t_sure').innerHTML = "<span style='color:red'>两次输入密码不一致</span>"
			}
		}else{
			document.getElementById('t_new').innerHTML = "<span style='color:red'>密码长度六位到十六位</span>"
		}
		return status;
	}
</script>
</body>
</html>